<?php
$user_role = $this->session->userdata('admin_role');

$selected_cat = set_value('dang_dich_vu');
$selected_cat_setting = array(
    'table_name' => 'dang_dichvu',
    'key_field' => 'id',
    'value_field' => 'ten_dich_vu'
);

$user_id = $this->session->userdata('admin_id');

//set month
$months = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep",
    "Oct", "Nov", "Dec");
ini_set("date.timezone", "Europe/Paris");

//get year
$this_day = now();
$pattern = "%Y";
$pattern_date = "%Y-%m-%d";
$str_year = mdate($pattern, $this_day);
$str_date = mdate($pattern_date, $this_day);
for ($i = 0; $i < 12; $i++) {
    $dropdown_data[$i + 1] = $months[$i];
}
for ($i = 0; $i < 31; $i++) {
    $day_data[$i + 1] = $i + 1;
}
for ($i = $str_year + 10; $i > $str_year - 80; $i--) {
    $year_data[$i] = $i;
}
?>
<div id="content">
    <div id="title_content">Thêm nhanh thanh toán</div>
    <?php if ($this->session->flashdata('error')): ?>
        <div class="affiche_erreur">
            <?php echo $this->session->flashdata('error'); ?>
        </div>
    <?php endif; ?>


    <style>
        .customer_infor {
            border: 1px solid black;
            height:260px;
            margin-bottom: 20px;
            width: 300px;
            float:left;
        }

        .customer_infor .post_number {
            padding-left: 10px;
            background: #8f8a7f;
            height: 20px;
            color: #ffffff;
            font-size: 16px;
        }

        .customer_infor .post_content {
            margin-left: 10px;
        }

        .customer_infor .post_content ul li{
            float:none !important;
        }

        .customer_infor .post_content ul li span.label{
            margin-right: 10px;
            font-family: Arial, sans-serif;
            font-weight: bold;
            color: #222222;

        }

        .wrapper_customer {
            height:380px;
        }
    </style>

    <div class="wrapper_customer">
        <div class="customer_infor">

            <div class="post_number">Thông tin khách hàng</div>
            <div class="post_content">
                <ul>
                    <li>
                        <span class="label">Họ tên :</span>
                        <span class="value"><?php echo $khach_hang->ten_khach_hang; ?></span>
                    </li>
                    <li>
                        <span class="label">Công ty :</span>
                        <span class="value"><?php echo $khach_hang->ten_cong_ty; ?></span>
                    </li>
                    <li>
                        <span class="label">Điện thoại :</span>
                        <span class="value"><?php echo $khach_hang->dien_thoai; ?></span>
                    </li>
                    <li>
                        <span class="label">Email :</span>
                        <span class="value"><?php echo $khach_hang->email; ?></span>
                    </li>
                    <li>
                        <span class="label">Địa chỉ :</span>
                        <span class="value"><?php echo $khach_hang->dia_chi; ?></span>
                    </li>

                    <li>

                    </li>
                </ul>
            </div>
        </div>
        <!-- End .customer_infor -->

        <div class="form_add_pay" style="float:right; width: 665px;">
            <?php echo form_open('thanh_toan/them_thanh_toan/' . $dich_vu->id, array('id' => 'register')); ?>
            <div id="content">
                <?php if ($this->session->flashdata('warning')): ?>
                    <div class="affiche_erreur">
                        <?php echo $this->session->flashdata('warning'); ?>
                    </div>
                <?php endif; ?>

                <?php echo form_open_multipart('thanh_toan/them_thanh_toan/' . $dich_vu->id); ?>
                <table class="form_content" width="100%">

                    <tr>
                        <td>Số tiền </td>
                        <td>
                            <?php if (form_error('so_tien') != "") {
                                ?> <div class="form_error"><?php echo generate_pure_text(form_error('so_tien'), '<p>', '</p>'); ?></div> <?php } ?>
                            <input type="text" class="form_input" name="so_tien" size="35" maxlength="40" value="<?php echo set_value('so_tien'); ?>" /></td>
                    </tr>

                    <tr>
                        <td>Ngày trả tiền</td>
                        <td>
                            D : <?php echo form_dropdown('pay_date', $day_data, get_date_part($str_date, 'day'), 'id="day" class="short"'); ?>
                            M : <?php echo form_dropdown('pay_month', $dropdown_data, get_date_part($str_date, 'month'), 'id="month" class="short"'); ?>
                            Y : <?php echo form_dropdown('pay_year', $year_data, get_date_part($str_date, 'year'), 'id="year" class="short"'); ?>
                        </td>
                    </tr>

                    <tr>
                        <td>Chi tiết </td>
                        <td>
                            <?php if (form_error('chi_tiet') != "") {
                                ?> <div class="form_error"><?php echo generate_pure_text(form_error('chi_tiet'), '<p>', '</p>'); ?></div> <?php } ?>

                            <textarea name="chi_tiet" cols="80" rows="10"><?php echo set_value('chi_tiet'); ?></textarea>
                        </td>
                    </tr>

                    <tr>
                        <td></td>
                        <td colspan="2"><input type="submit" name="submit" value="Thêm" class="form_submit" /></td>
                    </tr>
                </table>
                <?php echo form_close(); ?>
            </div>
            <div style="clear:both;"></div>
        </div>
    </div>
    <!-- End .wrapper_customer -->

    <style>
        .wrapper_pay_infor {
            margin-bottom: 10px;

        }

        .wrapper_pay_infor h1{
            border-bottom: 1px solid #C8C8C8;
            color: #C8C8C8;
            font-size: 24px;
            margin: 20px 0;
        }

        .no_pay {
            color: red;
        }

        .pay {
            color: green;
        }


    </style>

    <div class="wrapper_pay_infor">
        <h1>
            Thông tin thanh toán dịch vụ <span style="color: #444444;"><?php echo $dich_vu->ten_dich_vu; ?></span> - Website <span style="color: #444444;"><?php echo $dich_vu->ten_website; ?></span>        
        </h1>

        <table class="list" width="100%">
            <thead>
                <tr>

                    <th>Số tiền </th>
                    <th>Ngày trả</th>
                    <th>Ghi chú</th>
                     <?php if ($user_role == '1'): ?>
                    <th>Action</th>
                     <?php endif; ?>

                </tr>
            </thead>
            <tbody>
                <?php
                if (isset($data) && !empty($data)):
                    foreach ($data as $aRow):
                        ?>
                        <tr>
                            <td><?php echo $aRow['tien']; ?></td>
                            <td><?php echo date('d/m/Y', $aRow['ngay_thanh_toan']); ?></td>
                            <td><?php echo $aRow['ghi_chu']; ?></td>
                             <?php if ($user_role == '1'): ?>
                            <td width="30px"><a class="confirm_delete" href="<?php echo site_url('thanh_toan/xoa_dot_thanh_toan/' . $aRow['id_dot_thanh_toan'].'/'.$dich_vu->id.'/'.$aRow['id']) ?>"><img src="<?php echo base_url() ?>assets/admin/images/supprimer.png" alt="supprimer"/></a></td>
                            <?php endif; ?>
                        </tr>
                    <?php endforeach; ?>
                <?php endif; ?>
            </tbody>
        </table>

    </div><!-- End .wrapper_pay_infor -->





</div>
<!--END content-->
